import React from 'react';
import { Input, Button } from 'antd';
import UploadImg from '../../../component/Upload/Upload';
import { inject, observer } from 'mobx-react';
@inject('addGoodsMobx')
@observer
class GoodsSpecifications extends React.Component {
  render() {
    const { delList, index } = this.props;
    const { formChangePro } = this.props.addGoodsMobx;
    let o = '';
    if (this.props.item) {
      o = this.props.item;
    }
    return (
      <>
        <tr>
          <td>
            <Input
              defaultValue={o.comspecName}
              onChange={e => formChangePro(index, 0, 'comspecName', e.target.value)}
            />
          </td>
          <td>
            <Input
              defaultValue={o.goodsId}
              onChange={e => formChangePro(index, 0, 'number', e.target.value)}
            />
          </td>
          <td>
            <Input
              type="number"
              min={0}
              defaultValue={o.space}
              onChange={e => formChangePro(index, 0, 'space', e.target.value)}
            />
          </td>
          <td>
            <Input
              type="number"
              min={0}
              defaultValue={o.inventory}
              onChange={e => formChangePro(index, 0, 'inventory', e.target.value)}
            />
          </td>
          <td>
            <UploadImg
              maxNum={1}
              Size={2}
              type="specifyImg"
              index={index}
              defaultValue={o.pageUrl}
              ok="ok"
            />
          </td>
          <td>
            <Button type="link" onClick={() => delList(index)}>
              删除
            </Button>
          </td>
        </tr>
      </>
    );
  }
}
function getBase64(file) {
  return new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = () => resolve(reader.result);
    reader.onerror = error => reject(error);
  });
}
export default GoodsSpecifications;
